package com.wlz.dependencies;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author wlz
 * @date 2022-05-25  9:12 下午
 */
public class JdkDynimcProxy implements InvocationHandler {


	private Object target;

	public JdkDynimcProxy(Object target) {
		this.target = target;
	}

	@SuppressWarnings("unchecked")
	public <T> T getProxy() {
		return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),target.getClass().getInterfaces(),this);
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("JdkDynimcProxy invoke .....");
		return method.invoke(target,args);
	}
}
